package cn.thrjit.autoconfigure;

import cn.thrjit.properties.AppSettingProperties;
import cn.thrjit.template.AppWeChatTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({AppSettingProperties.class})
public class WeChatAutoConfiguration {


    @Bean
    @ConditionalOnMissingBean(
            name = {"appWeChatTemplate"}
    )
    // 接收AppSettingProperties从云端获取的配置
    public AppWeChatTemplate weChatTemplate(AppSettingProperties appSettingProperties){
        // 通过构造器把数据传到AppWeChatTemplate
        AppWeChatTemplate appWeChatTemplate = new AppWeChatTemplate(appSettingProperties);
        return appWeChatTemplate;
    }

}
